/*
 * @Author: wangdian
 * @Date: 2023-06-07 10:55:58
 * @LastEditors: wangdian
 * @LastEditTime: 2023-06-07 11:03:04
 * @Description: file content
 * @FilePath: \workspace\compress.js
 */
// 目录下生成了 input.txt 的压缩文件 input.txt.gz。
var fs = require("fs");
var zlib = require('zlib');

// 压缩 input.txt 文件为 input.txt.gz
fs.createReadStream('input.txt')
    .pipe(zlib.createGzip())
    .pipe(fs.createWriteStream('input.txt.gz'));

console.log("文件压缩完成。");